package com.example.bgmachine.bgmachine.goods;

import android.util.Log;

import com.example.bgmachine.bgmachine.Urlinfor;

public class HomepageGridRightMenuItemData {
    private int menuId  =0;
    private String menuNames ="";
    private String imagePaths ="";

    private String contents ="";

    public HomepageGridRightMenuItemData() {
    }
    public HomepageGridRightMenuItemData(int menuId, String menuNames , String contents) {
        this.menuId = menuId;
        this.menuNames = menuNames;
        this.contents = contents;


    }
    public HomepageGridRightMenuItemData(int menuId, String menuNames ,String imagePaths, String contents) {
        this.menuId = menuId;
        this.menuNames = menuNames;
       String imagPatha ="";
       if(imagePaths != null){
           imagPatha  = getFileName(imagePaths);
       }
       if(imagPatha != null && imagPatha.length() > 0){
           this.imagePaths = imagPatha ;
       }else{
           this.imagePaths = "" ;
       }
        Log.d("aaa", "HomepageGridRightMenuItemData="+this.imagePaths);
        this.contents = contents;

    }
    public String getFileName(String pathandname){

        int start=pathandname.lastIndexOf("/");
        int end=pathandname.lastIndexOf(".");

        if(start!=-1 && end!=-1){
            int lena = pathandname.length();
            String pthsa = pathandname.substring(start+1,end);
            String pthsb = pathandname.substring(end,lena);
            String pthsc= pthsa+pthsb;
            return pthsc;
        }else{
            if(pathandname.length() > 0 && end!=-1){
                return pathandname;
            }else{
                return "";
            }

        }

    }
    public void setMenuId(int menuId) {
        this.menuId = menuId;
    }

    public void setMenuNames(String menuNames) {
        this.menuNames = menuNames;
    }

    public void setImagePaths(String imagePaths) {
        String imagPatha ="";
        if(imagPatha != null){
            imagPatha  = getFileName(imagePaths);
        }
        if(imagPatha != null && imagPatha.length() > 0){
            this.imagePaths = imagPatha ;
        }else{
            this.imagePaths = "" ;
        }
    }

    public void setContents(String contents) {
        this.contents = contents;
    }

    public int getMenuId() {
        return menuId;
    }

    public String getMenuNames() {
        return menuNames;
    }

    public String getImagePaths() {
        return imagePaths;
    }

    public String getContents() {
        return contents;
    }
}
